#Author: Tanyong
# *-* coding:utf8 *-*
# @time       : 18-7-17 上午11:40
# @Author     : Tanyong
# @Site       : 
# @File       : config.py
# @Software   : PyCharm
import logging
from redis import StrictRedis


class Config():
    # 开启调试模式
    DEBUG = True

    SECRET_KEY = "EjpNVSNQTyGi1VvWECj9TvC/+kq3oujee2kTfQUs8yCM6xX9Yjq52v54g+HVoknA"

    # 数据库配置
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information_test"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # redis配置
    REDIS_HOST = "192.168.56.132"
    REDIS_PORT = 6379

    # Session配置
    # 设置session的存储位置为 redis
    SESSION_TYPE = "redis"
    # 设置redis 的端口核Ip
    SESSION_REDIS = StrictRedis(REDIS_HOST, REDIS_PORT)
    # 设置session签名， 加密
    SESSION_USE_SIGNER = True
    # 将session的永久有效关闭， 因为我们只需要它有效一段时间
    SESSION_PERMANENT = False
    # 设置session 的有效时间为 2天
    PERMANENT_SESSION_LIFETIME = 86400 * 2

    # 日志等级配置
    LOG_LEVEL = logging.DEBUG

class DevelopementConfig(Config):
    """开发模式下的配置"""
    DEBUG = True


class ProductionConfig(Config):
    """生产模式下的配置"""
    DEBUG = False
    LOG_LEVEL = logging.WARNING

class TestingCondig(Config):
    """单元测试的配置"""
    DEBUG = True
    TESTING = True

config = {
    "development": DevelopementConfig,
    "production": ProductionConfig,
    "testing": TestingCondig
}